package com.toidep.entities;

import org.json.JSONObject;

import com.toidep.api.ParseJSON;
import com.toidep.config.Constants;
import com.toidep.utilities.StringUtility;

public class ArticleEntity {

	private int id;
	private String title;
	private String introText;
	private String imageUrl;
	private String model_id;
	private String content;
	private String type;
	private String total_view;
	private String total_like;
	private String total_comment;
	private String created;
	
	public ArticleEntity() {
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getIntroText() {
		return introText;
	}

	public void setIntroText(String introText) {
		this.introText = introText;
	}

	public String getImageUrl() {
		return imageUrl;
	}

	public void setImageUrl(String imageUrl) {
		this.imageUrl = imageUrl;
	}

	public String getModel_id() {
		return model_id;
	}

	public void setModel_id(String model_id) {
		this.model_id = model_id;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getTotal_view() {
		return total_view;
	}

	public void setTotal_view(String total_view) {
		this.total_view = total_view;
	}

	public String getTotal_like() {
		return total_like;
	}

	public void setTotal_like(String total_like) {
		this.total_like = total_like;
	}

	public String getTotal_comment() {
		return total_comment;
	}

	public void setTotal_comment(String total_comment) {
		this.total_comment = total_comment;
	}

	public String getCreated() {
		return created;
	}

	public void setCreated(String created) {
		this.created = created;
	}

	public void setInfo(JSONObject jsonObject) {
		
		// common
		this.id = ParseJSON.getIntValue(jsonObject, Constants.PARAM_RESPONSE_ID);
		this.title = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_TITLE);
		this.introText = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_INTROTEXT);
		
		String imageUrl = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_URL_IMAGE);
		imageUrl = imageUrl.equals("") ? ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_IMAGE) : imageUrl;
		this.imageUrl = StringUtility.parseImageUrl(imageUrl);
		
		this.content = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_CONTENT);
		this.model_id = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_MODEL_ID);
		this.type = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_TYPE);
		this.total_view = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_TOTAL_VIEW);
		this.total_like = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_TOTAL_LIKE);
		this.total_comment = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_TOTAL_COMMENT);
		this.created = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_CREATED);
	}
	
}
